package com.pvdnc.xdynamic.loader;

import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;

import com.pvdnc.xdynamic.loader.mirror.android.content.res.RAssetManager;

import java.io.File;

public class ResourceUtils {
    public static Resources getResources(Context context, File apkFile) throws Exception{
        AssetManager asset= AssetManager.class.newInstance();
        RAssetManager.addAssetPath.call(asset,apkFile.getAbsolutePath());
        Resources hostRes = context.getResources();
        Resources apkRes= new Resources(asset,
                hostRes.getDisplayMetrics(), hostRes.getConfiguration());
        return apkRes;
    }

    public static void mergeResources(Context context,File apkFile){
        AssetManager assetManager=context.getAssets();
        RAssetManager.addAssetPath.call(assetManager,apkFile.getAbsolutePath());
    }
}
